﻿<!DOCTYPE html>
<html class="hf">
  <head>
    <meta charset="UTF-8" />
    <title>本地测试-h265</title>
    <meta
      name="viewport"
      content="width=device-width,initial-scale=1,minimum-scale=1,maximum-scale=1,user-scalable=no"
    />
    <link rel="stylesheet" type="text/css" href="/h265/styles/global.css" />
    <!-- <script src="/h265/vconsole.min.js"></script>
    <script>
      if (
        navigator.userAgent.toLowerCase().indexOf("windows") < 0 &&
        navigator.userAgent.toLowerCase().indexOf("webdebugger") < 0
      )
        var vConsole = new VConsole();
    </script> -->
    <style>
      /*禁止浏览器左右滑动*/
      html {
        touch-action: none;
        touch-action: pan-y;
      }
      .dvdvdv {
        width: 100%;
      }
      .dvdvdv img {
        width: 100%;
      }
    </style>
  </head>
  <body class="hf">
    <div id="abc" class="ybl" style="width: 100%; height: 300px">
      <iframe
        id="mp"
        src="/h265/player.html"
        style="width: 100%; height: 100%"
        allowfullscreen="allowfullscreen"
        mozallowfullscreen="mozallowfullscreen"
        msallowfullscreen="msallowfullscreen"
        oallowfullscreen="oallowfullscreen"
        webkitallowfullscreen="webkitallowfullscreen"
      ></iframe>
      <!--<button onclick="autoScreen()" style="font-size: 100px;">页面其他控件</button>-->
    </div>
    <div onclick="tapsendMessage()" class="dvdvdv">
      <div class="wf bx1 pa hf"></div>
      <img src="img/Snipaste_2020-09-01_15-05-55.png" />
    </div>
    <div class="dvdvdv"><img src="img/Snipaste_2020-09-01_15-07-25.png" /></div>
    <div class="dvdvdv"><img src="img/Snipaste_2020-09-01_15-07-46.png" /></div>
    <script>
      const video = document.getElementById("video");
      const iframe = document.getElementById("mp");

      fElement = iframe;
      isFull = false;
      function autoScreen() {
        const a = document.getElementsByClassName("vc-panel");
        let t = iframe.contentWindow.postMessage({ a: 1, b: 2 }, "*");
      }
      indexURL = "";
      //切换资源
      function tapsendMessage() {
        // let a = "https://h265.shuoyingkeji.com/shbk3/index.m3u8"; //要切换的资源
        let a = "http://video2.nanme.top/video/265_1080/index.m3u8"; //要切换的资源
        let b = "http://video2.nanme.top/video/265_720/index.m3u8"; //要切换的资源
        a =
          "https://douban.donghongzuida.com/20200502/1454_a950891a/index.m3u8";
        a = "https://h265.shuoyingkeji.com/jzztd/index.m3u8";
        a = "http://video2.nanme.top/video/265_720_2/index.m3u8";
        indexURL = indexURL == a ? b : a;
        sendMessage(indexURL);
      }

      //向iframe内部传数据
      function sendMessage(url) {
        var frame = document.getElementById("mp");
        let data = {
          cmd: "getFormJson",
          params: {
            url: url,
            //cover:cover
          },
        };
        frame.contentWindow.postMessage(data, "*");
        console.log("向iframe内部传数据", url);
      }
      self.onmessage = function (e) {
        switch (e.data.cmd) {
          case "returnHeight":
            console.log("接受到子页面页面发来的信息", e.data);
            // 处理业务逻辑
            autoplay();
            break;
          case "aa":
            console.log(dp.pl);
            break;
        }
      };
      function sd() {
        var frame = document.getElementById("mp");
        let data = {
          cmd: "aa",
        };
        frame.contentWindow.postMessage(data, "*");
      }
      //模仿获取数据
      function autoplay() {
        setTimeout(function () {
          let ifram2 = document.getElementById("mp");
          if (ifram2 != null) {
            console.log("动态修改播放资源地址");
            tapsendMessage();
          }
        }, 500);
      }
    </script>
  </body>
</html>
